home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_013 / othello.abc < prev    next >
Text File  |  1992-05-06  |  7KB  |  225 lines

  1. 10    REM OTHELLO
  2. 20    DIM A(10,10),I4(9),J4(9),strat%(10,10)
  3. 30    for i=1 to 10: for j=1 to 10:strat%(i,j)=0:next j,i
  4. 40    SCREEN 1,4,0
  5. 50    SCNCLR
  6. 60    PENA 1
  7. 70    dim green%(1), red%(1),gblock%(125),square%(500)
  8. 80    green%(0)=0: red%(0)=&HFFFF
  9. 90    w=39:h=17: pc=1: rem width and height of board squares; fill piece circles.
  10. 100   window #1, 250,11,8*w+62,8*h+47,"Othello"
  11. 110   window #2,0,11,250,189,"Othello"
  12. 120   cmd 2: pena 1
  13. 130   scnclr
  14. 140   f2=0
  15. 150   gosub 1560
  16. 160   PRINT"Should I wait for your click before completing my play? - (click twice on Y or N)": gosub 2200
  17. 170   if x$="N" then 200
  18. 180   if x$<>"Y" then 160
  19. 190   f2=1
  20. 200   for i=1 to 10:for j=1 to 10:strat%(i,j)=0:next j,i
  21. 210   print"Shall I use my best strategy? (Click Y or N)": gosub 2200
  22. 220   if x$="N" then 280
  23. 230   if x$<>"Y" then 210
  24. 240   data 4,-1,2,2,2,2,-1,4
  25. 250   for i=2 to 9 step 7:restore 240: for j=2 to 9:read strat%(i,j): next j,i
  26. 260   for j=2 to 9 step 7: restore 240: for i=2 to 9:read strat%(i,j): next i,j
  27. 270   FOR I=3 TO 8 STEP 5:FOR J=3 TO 8 STEP 5:STRAT%(I,J)=-1:NEXT J,I
  28. 280   B=-1: Wt=1
  29. 290   restore 310
  30. 300   FOR K =2 TO 9:READ I4(K):NEXT
  31. 310   DATA 0,-1,-1,-1,0,1,1,1
  32. 320   FOR K =2 TO 9:READ J4(K): NEXT
  33. 330   DATA 1,1,0,-1,-1,-1,0,1
  34. 340   FOR I = 1 TO 10: FOR J = 1 TO 10: A(I,J)=0:NEXT J,I
  35. 350   A(5,5)=Wt:A(6,6)=Wt:A(5,6)=B:A(6,5)=B
  36. 360   C1 =2:H1 =2: Z =0
  37. 370   N1 =4
  38. 380   hu=wt:c=b
  39. 390   Print# 2, "You will play White."
  40. 400   gosub 1560 : rem draw board and pieces.
  41. 410   ?"Do you want to go first?   (Click Y or N)"
  42. 420   gosub 2200
  43. 430   IF X$ = "N" THEN 460
  44. 440   IF X$<>"Y" THEN 410
  45. 450   GOTO 790
  46. 460   print"I'm thinking.": B1=-1:J3=0:I3=0:T1=C:T2=Hu
  47. 470   FOR I = 2 TO 9
  48. 480   FOR J = 2 TO 9
  49. 490   IF A(I,J)<>0 THEN 580
  50. 500   GOSUB 1340
  51. 510   IF F1 = 0 THEN 580
  52. 520   U=-1:GOSUB 1420: IF S1=0 THEN 580
  53. 530   S1=S1+STRAT%(I,J)
  54. 540   IF S1<B1 THEN 580
  55. 550   IF S1>B1 THEN 570
  56. 560   IF RND(100)>50 THEN 580
  57. 570   B1 = S1: I3 = I:J3 = J
  58. 580   NEXT J,I
  59. 590   IF B1>0 THEN 630
  60. 600   PRINT"I have to forfeit my move."
  61. 610   IF Z = 1 THEN 1060
  62. 620   Z = 1: GOTO 790
  63. 630   Z=0
  64. 640   print"I'll circle my next move"
  65. 650   pc=0:x=i3-2:y=j3-2:cmd 1:gosub 1720:pc=1
  66. 660   i=i3:J=J3:GOSUB 1420: rem get # captured pieces.
  67. 670   C1=C1+S1+1:H1=H1-S1:N1=N1+1
  68. 680   PRINT"That will give me"
  69. 690   print s1;" of your pieces."
  70. 700   IF F2=0 THEN SLEEP 3E6: GOTO 760
  71. 710   print"Click left button when" 
  72. 720   print"you're ready for me to"
  73. 730   print"complete my play."
  74. 740   ask mouse x%,y%,b%
  75. 750   if b%=0 goto 740
  76. 760   i=i3:j=j3:u=1:gosub 1420: rem flip captured pieces
  77. 770   IF H1=0 THEN 1060
  78. 780   IF N1=64 THEN 1060
  79. 790   T1=Hu:T2=C
  80. 800   print "Click on your move square."
  81. 810   cmd 1: gosub 1820: cmd 2
  82. 820   If y>7 and y<10 then if x>3 and x<7 then pr%=1   else if x>0 and x<4 then pr%=2   else pr%=4     else if y>-1 and y<8 and x>-1 and x<8 then pr%=3   else pr%=4
  83. 830   on pr% goto 1280,840,880,800
  84. 840   print"You are forfeiting your turn."
  85. 850   if z=1 then 1060
  86. 860   z=1
  87. 870   goto 460
  88. 880   I=X+2: J=Y+2: IF A(I,J)=0 THEN 910
  89. 890   PRINT"Sorry; that square is"
  90. 900   print"occupied; try again.": goto 800
  91. 910   gosub 1340: if f1=1 then 950
  92. 920   print"Sorry; you're not next to "
  93. 930   print " one of my pieces;"
  94. 940   print"Try again.":goto 800
  95. 950   u=-1: gosub 1420: if s1>0 then 990
  96. 960   print"Sorry, that doesn't flank"
  97. 970   print"a row; try again."
  98. 980   goto 800
  99. 990   Z=0:PRINT"That gives you "
  100. 1000  print s1;" of my pieces."
  101. 1010  U=1: GOSUB 1420
  102. 1020  H1=H1+S1+1: C1=C1-S1: N1=N1+1
  103. 1030  IF C1=0 THEN 1060
  104. 1040  IF N1=64 THEN 1060
  105. 1050  GOTO 460
  106. 1060  PRINT: PRINT"You have ";H1;" pieces,"
  107. 1070  print "and I have ";C1;" pieces."
  108. 1080  IF H1=C1 THEN 1120
  109. 1090  IF H1>C1 THEN 1130
  110. 1100  PRINT"Sorry, I won that one."
  111. 1110  GOTO 1140
  112. 1120  PRINT"A Tie!": goto 1270
  113. 1130  PRINT"YOU WON!!"
  114. 1140  C1=C1-H1: IF C1>0 THEN 1160
  115. 1150  C1=-C1
  116. 1160  C1=64*C1/N1
  117. 1170  PRINT"That was a ";
  118. 1180  IF C1<11 THEN 1260
  119. 1190  IF C1<25 THEN 1250:'
  120. 1200  if c1<39 then 1240
  121. 1210  if C1<53 then 1230
  122. 1220  PRINT"PERFECT GAME!": GOTO 1270
  123. 1230  PRINT"Walkaway.": GOTO 1270
  124. 1240  PRINT"Real Fight.": goto 1270
  125. 1250  PRINT"Hot Game!": goto 1270
  126. 1260  print"Squeaker!!"
  127. 1270  PRINT
  128. 1280  print"Do you want to play another game? (Click Y or N)"
  129. 1290  gosub 2200
  130. 1300  if x$="Y" THEN RESTORE 310: GOTO 200
  131. 1310  PRINT"Thanks for playing!"
  132. 1320  cmd 0: close #1
  133. 1330  END
  134. 1340  F1=0: FOR I1 = -1 TO 1
  135. 1350  FOR J1= -1 TO 1
  136. 1360  IF A(I+I1, J+J1)=T2 THEN F1=1:I1=1:J1=1
  137. 1370  NEXT  J1, I1
  138. 1380  RETURN
  139. 1390  REM
  140. 1400  REM
  141. 1410  REM
  142. 1420  S1=0
  143. 1430  FOR K=2 TO 9:I5=I4(K):J5=J4(K):I6=I+I5:J6=J+J5
  144. 1440  S3=0: IF A(I6,J6)<>T2 THEN 1510
  145. 1450  S3=S3+1:I6=I6+I5:J6=J6+J5:IF A(I6,J6)=T1 THEN 1480
  146. 1460  IF A(I6,J6)=0 THEN 1510
  147. 1470  GOTO 1450
  148. 1480  S1=S1+S3: IF U<>1 THEN 1510
  149. 1490  I6=I:J6=J: FOR K1=0 TO S3
  150. 1500  A(I6,J6)=T1: gosub 2180: I6=I6+I5:J6=J6+J5:NEXT K1
  151. 1510  NEXT K
  152. 1520  RETURN
  153. 1530  REM
  154. 1540  REM
  155. 1550  REM
  156. 1560  cmd 1: gosub 1890:  rem Draw Game Board
  157. 1570  for i=2 to 9: for j=2 to 9
  158. 1580  state%=A(i,j)+2: x=i-2: y=j-2
  159. 1590  on state% gosub 1690, 1700, 1680
  160. 1600  next j,i
  161. 1610  cmd 2: pena 1
  162. 1620  return
  163. 1630  rem ***** end routine *****
  164. 1640  scnclr : cmd
  165. 1650  close #1
  166. 1660  end
  167. 1670  rem ***** the white and black piece plotters *****
  168. 1680  cmd 1: PENA 2: PENO 2: goto 1720: rem white piece maker.
  169. 1690  cmd 1: PENA 1: PENO 1: goto 1720: rem black piece maker
  170. 1700  return: rem dummy; don't-put-piece subroutine.
  171. 1710  rem
  172. 1720  rem ***** piece maker *****
  173. 1730  cx0=x0+int(w/2)+x*w  : cy0=int(h/2)+y*h
  174. 1740  circle(cx0,cy0),int(w/6)
  175. 1750  if pc=0 then 1780
  176. 1760  pattern 1,red%
  177. 1770  paint(cx0,cy0),1
  178. 1780  pena 1: PENO 2: cmd 2
  179. 1790  return
  180. 1800  rem
  181. 1810  rem
  182. 1820  REM ***** Get x, y of mouse when left button pressed.
  183. 1830  REM
  184. 1840  rem
  185. 1850  ask mouse xm%,ym%,b%
  186. 1860  if b%=0 then 1850:'
  187. 1870  x=int((xm%-x0)/w):y=int(ym%/h)
  188. 1880  return
  189. 1890  rem ***** DRAW GAME BOARD *****
  190. 1900  peno 2: pena 4:penb 8
  191. 1910  pattern 1, red%
  192. 1920  outline 0
  193. 1930  wb=8*w: hb=8*h
  194. 1940  x0=30
  195. 1950  area( x0,0 to x0+wb-1,0 to x0+wb-1,hb-1 to x0,hb-1 )
  196. 1960  pattern 1, green%
  197. 1970  area (x0,0 to x0+w-1,0 to x0+w-1,h-1 to x0,h-1)
  198. 1980  sshape(x0,0;x0+w,h),gblock%
  199. 1990  gshape(x0+w,h),gblock%
  200. 2000  sshape(X0,0;X0+2*w,2*h),square%
  201. 2010  for i=X0 to X0+6*w step 2*w
  202. 2020  for j=0 to 6*h step 2*h
  203. 2030  gshape(i,j),square%
  204. 2040  next j,i
  205. 2050  rem
  206. 2060  rem
  207. 2070  rem ***** draw forfeit and quit boxes
  208. 2080  rem
  209. 2090  rem
  210. 2100  box (x0+60,144;x0+140,159) : box(x0+172,144;x0+252,159)
  211. 2110  BOX(X0,144;X0+35,159):BOX(X0+277,144;X0+312,159)
  212. 2120  GRAPHIC (1)
  213. 2130  print at (103,154);"FORFEIT"; AT (215,154);" QUIT. "
  214. 2140  PRINT AT(X0+5,154);"YES"; AT (X0+282,154);"NO."
  215. 2150  graphic(0)
  216. 2160  CMD 2: PENA 1
  217. 2170  return
  218. 2180  x=i6-2:y=j6-2: if t1=hu then gosub 1680 else gosub 1690
  219. 2190  return
  220. 2200  REM SUBRTN TO GET YES OR NO FROM MOUSE.
  221. 2210  REM
  222. 2220  CMD 1: GOSUB 1820: CMD 2
  223. 2230  IF Y>7 AND Y<10 THEN   IF X=0 THEN X$="Y"   ELSE IF X = 7 THEN X$ = "N" ELSE X$=""   ELSE X$=""
  224. 2240  RETURN